﻿using Microsoft.EntityFrameworkCore;
using MySpiderMgr.Domain.Common;
using MySpiderMgr.Domain.Resources;
using System;
using System.Collections.Generic;
using System.Text;

namespace MySpiderMgr.Data.EF
{
    public class MyDbContext : DbContext
    {
        /// <summary>
        /// 系统资源
        /// </summary>
        public DbSet<SysResource> SysResources { get; set; }
        /// <summary>
        /// 系统序列
        /// </summary>
        public DbSet<SysSequence> SysSequences { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<SysResource>().ToTable("SysResource").HasKey(s => s.Id);
            modelBuilder.Entity<SysResource>().Ignore(s => s.Actions);
            //SysSequences

            modelBuilder.Entity<SysSequence>().ToTable("SysSequence").HasKey(s => s.Id);
        }
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlServer(DBHelper.GetConnectionString());

        }
    }
}
